import React from 'react'
import { Form, Input, Button, Row, Col, message } from 'antd';
import MyTable from './../MyTable/MyTable';
import myAxios from '../../../utils/myAxios';
export default function CollideBill() {
  const initcolumns = [
    {
      title: '序号',
      dataIndex: 'serialNumber',
    },
    {
      title: '客户名称',
      dataIndex: 'name',
      render: (a, e) => <a onClick={() => { console.log(a, e); }}>{a}</a>,
    },
    {
      title: '手机号码',
      dataIndex: 'phone',
    },
    {
      title: '录入时间',
      dataIndex: 'time',
    },
    {
      title: '部门',
      dataIndex: 'department',
    },
    {
      title: '业务员',
      dataIndex: 'salesman',
    },
  ]
  function onFinish(value) {
    const { phone, username } = value
    let obj={type: 1, page: 1, limit: 0, customerUsername: username, phoneNumber: phone}
    if (phone == undefined && username == undefined) {
      message.warning('亲~，请至少输入一项查询条件~~')
    } else {
      myAxios({
        method: 'post',
        url: '/customer/findLikeCustomer',
        data: obj
      })
        .then(res => {
          if (res.data.code !== 200) {
            message.success('亲~，没有撞单的客户哦~~')
          }
        })
    }

  }
  return (
    <div>
      <Row>
        <Col offset={11} span={2}>
          <h2 style={{ fontWeight: '600' }}>撞单查询</h2>
        </Col>
      </Row>
      <hr />
      <Form
        name="basic"
        labelCol={{ span: 9 }}
        wrapperCol={{ span: 6 }}
        initialValues={{ remember: true }}
        onFinish={onFinish}

      >
        <Form.Item
          label="客户名称"
          name="username"
        >
          <Input />
        </Form.Item>
        <Form.Item
          label="手机号码"
          name="phone"
          style={{ marginBottom: 10 }}
        >
          <Input />
        </Form.Item>
        <Form.Item wrapperCol={{ offset: 11, span: 2 }}>
          <Button
            onClick={() => { }}
            type="primary" htmlType="submit">
            立即查询
          </Button>
        </Form.Item>
      </Form>
      <MyTable columns={initcolumns} />

    </div>
  )
}
